<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<c:set var="reportTitle" value="产品分类报表" scope="session"/>

<%@ include file="/common/report_head.jsp" %>
<%@ include file="/condition/sartTime_YMDH_input.html"%>
<%@ include file="/condition/endTime_YMDH_input.html"%>
<%@ include file="/condition/ivLine_sumo.html"%>
<%@ include file="/condition/productMaterial_sumo.html"%>
<%@ include file="/condition/bomMaterial_sumo.html"%>

<%@ include file="/common/report_middle.jsp" %>
<div class="col-md-12" style="height: 820px;">
    <div id="pqGrid"></div>
</div>
<%@include file="/common/report_end.jsp" %>

<style>
    .pq-col-green {background-color: #9BBB59}
</style>


<script>
    $(document).ready(function () {
        $("title").text("产品分类报表");
        $("label:contains('原材料料号:')").addClass("keyCss");

        $('#query_btn').click(function (){
            if($("#bomMaterialSumo").val() === null || $("#bomMaterialSumo").val() === ''){
                showErrorDialog("0000002", "原材料料号为必选项"); return false;
            }
            initGridAndChart();
            ajax('/jn-report/report/productClassify_report.do' ,loadConditionMapData(), true, ajax_successful);

            function ajax_successful(outTrxObj) {
                if(outTrxObj.gridData.length < 1) { showMessengerDialog("数据查询为空"); return false; }

                //grid表格数据
                var colM =[
                    {halign:"center",align:'center', dataIndx: 'attr_1',        title: '电池效率',       width: 150, editable: false, sortable: true},
                    {halign:"center",align:'center', dataIndx: '搭配',          title: '搭配',           width: 250, editable: false, sortable: true},
                    {halign:"center",align:'center', dataIndx: '平均功率',      title: '平均功率',       width: 150, editable: false, sortable: true},
                    {halign:"center",align:'center', dataIndx: '平均CTM',       title: '平均CTM',        width: 150, editable: false, sortable: true}
                ];
                for (var i=0; i<outTrxObj.dynamicColumn.length; i++){
                    var pm_name = outTrxObj.dynamicColumn[i];
                    colM.push({halign:'center', align:'center',  dataIndx: pm_name + '效率占比', title: pm_name, width: 150, editable: false, sortable: true});
                }
                colM.push({halign:"center",align:'center',dataIndx:'组件数量'	,title: '组件数量',	  width: 150,   editable: false, sortable: true});
                //colM.push({halign:"center",align:'center',dataIndx:'电池占比'	,title: '电池占比',	  width: 150,   editable: false, sortable: true, cls:'pq-col-green'});
                //colM.push({halign:"center",align:'center',dataIndx:'电池占比'	,title: '电池占比',	  width: 150,   editable: false, sortable: true});
                colM.push({halign:"center",align:'center',dataIndx:'电池产出占比'	,title: '电池产出占比',	  width: 150,   editable: false, sortable: true});
                for (var i=0; i<outTrxObj.dynamicColumn.length; i++){
                    var pm_name = outTrxObj.dynamicColumn[i];
                    colM.push({halign:'center', align:'center',  dataIndx: pm_name + '总占比', title: pm_name, width: 150, editable: false, sortable: true});
                }
                _pqUtil.f.setColModel($("#pqGrid"), colM);
                _pqUtil.f.seTitle($("#pqGrid"), "产品分类-表格");
                _pqUtil.f.isShowTitle($("#pqGrid"), false);
                _pqUtil.f.loadPqGridData($("#pqGrid"), outTrxObj.dynamicColumnJsonGridData);
            }
        });

    });
</script>
